home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / misc / math / MathFX_src.lha / fcnvrt.c < prev    next >
C/C++ Source or Header  |  1995-12-20  |  2KB  |  95 lines

  1. /* Coordinate transformations for plotting package */
  2.  
  3. #include "mathfx.h"
  4. #include "declare.h"
  5. #include <math.h>
  6.  
  7.  
  8.  
  9. /* dcmm. converts from device coordinates to millimetres from bottom */
  10. /* left-hand corner */
  11.  
  12. float dcmmx(x)
  13. float x;
  14. {
  15.       return((float)(x * abs(phyxma-phyxmi) / xpmm));
  16. }
  17.  
  18. float dcmmy(y)
  19. float y;
  20. {
  21.       return((float)(y * abs(phyyma-phyymi) / ypmm));
  22. }
  23.  
  24. /* dcsc. define transformations between device coordinates and subpage */
  25. /* coordinates */
  26.  
  27. float dcscx(x)
  28. float x;
  29. {
  30.       return((float)((x - spdxmi)/(spdxma-spdxmi)));
  31. }
  32.  
  33. float dcscy(y)
  34. float y;
  35. {
  36.       return((float)((y - spdymi)/(spdyma-spdymi)));
  37. }
  38.  
  39. /* mmdc. converts millimetres from bottom left corner into device */
  40. /* coordinates */
  41.  
  42. float mmdcx(x)
  43. float x;
  44. {
  45.       return((float)(x * xpmm / abs(phyxma - phyxmi)));
  46. }
  47.  
  48. float mmdcy(y)
  49. float y;
  50. {
  51.       return((float)(y * ypmm / abs(phyyma - phyymi)));
  52. }
  53.  
  54. /* scdc. converts subpage coordinates to device coordinates */
  55.  
  56. float scdcx(x)
  57. float x;
  58. {
  59.       return((float)(spdxmi + (spdxma-spdxmi) * x));
  60. }
  61.  
  62. float scdcy(y)
  63. float y;
  64. {
  65.       return((float)(spdymi + (spdyma-spdymi) * y));
  66. }
  67.  
  68. /* wcmm. converts world coordinates into millimetres */
  69.  
  70. float wcmmx(x)
  71. float x;
  72. {
  73.       return((float)(wmxoff + wmxscl*x));
  74. }
  75.  
  76. float wcmmy(y)
  77. float y;
  78. {
  79.       return((float)(wmyoff + wmyscl*y));
  80. }
  81.  
  82. float w3wcx(x,y,z)
  83. float x, y, z;
  84. {
  85.       return((float)((x-basecx)*cxx + (y-basecy)*cxy));
  86. }
  87.  
  88. float w3wcy(x,y,z)
  89. float x, y, z;
  90. {
  91.       return((float)((x-basecx)*cyx+(y-basecy)*cyy+(z-ranmi)*cyz));
  92. }
  93.  
  94.  
  95.